#include "generalconfiguerview.h"
#include "ui_generalconfiguerview.h"
#include <QSettings>

GeneralConfiguerView::GeneralConfiguerView(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::GeneralConfiguerView)
{
    ui->setupUi(this);
    setWindowTitle("通用配置");
    QSettings setting("conf.ini", QSettings::IniFormat);
    setting.beginGroup("System");
    ui->comboBox->setCurrentText(setting.value("language").toString());
    ui->lineEdit->setText(setting.value("queryGatewayStateCycle").toString());
    ui->lineEdit_2->setText(setting.value("queryDeviceStateCycle").toString());
    ui->lineEdit_3->setText(setting.value("gatewayCommunicationTimeout").toString());
    ui->lineEdit_4->setText(setting.value("faultyGatewayTestingCycle").toString());
    ui->lineEdit_5->setText(setting.value("supervisingNodeStateTimeout").toString());
}

GeneralConfiguerView::~GeneralConfiguerView()
{
    delete ui;
}

void GeneralConfiguerView::on_applyButton_clicked()
{
    QSettings setting("conf.ini", QSettings::IniFormat);
    setting.beginGroup("System");
    setting.setValue("language", ui->comboBox->currentText());
    setting.setValue("queryGatewayStateCycle", ui->lineEdit->text());
    setting.setValue("queryDeviceStateCycle", ui->lineEdit_2->text());
    setting.setValue("gatewayCommunicationTimeout", ui->lineEdit_3->text());
    setting.setValue("faultyGatewayTestingCycle", ui->lineEdit_4->text());
    setting.setValue("supervisingNodeStateTimeout", ui->lineEdit_5->text());
}
